package com.qf.dao;

import com.qf.entity.Bookxx;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *
 * @author 阿亘
 * @date 2023/07/14
 */
@Mapper
@Repository
public interface BookDao {
    @Select("select * from books")
    List<Bookxx> listBooks();

    @Select("select * from books where bookname = #{bookname}")
    Bookxx findBookByName(@Param("bookname") String bookname);

    int addBook(Bookxx book);

    @Delete("delete from books where bookid = #{bookid}")
    int deleteBool(@Param("bookid") Integer bookid);

    int updateBook(Bookxx book);

    @Update("update books set bookcount = bookcount - 1 where bookid = #{bookid}")
    int borrowBook(Integer bookid);

    @Update("update books set bookcount = bookcount + 1 where bookid = #{bookid}")
    int returnBook(Integer bookid);
}
